#include <LXMysql.h>
#include <iostream>

int test(LX::LXMysql &mysql)
{
    if (!mysql.Query(R"(SELECT name, `path`, `size`, id FROM t_image)"))
    {
        return 0;
    }
    mysql.StoreResult();
    std::cout << mysql.Rows() << std::endl;
    int len = mysql.Columns();
    while (mysql.Next())
    {
        for (size_t i = 0; i < len; i++)
        {
            std::cout << mysql.Value(i) << " ";
        }
        std::cout << std::endl;
    }
    return 0;
}
void test_Exec_FetchRow(LX::LXMysql &mysql)
{
    mysql.Exec(R"(SELECT `name`, `path`, `size`, `id` FROM t_image)");
    auto row=mysql.FetchRow();
    while (row.size())
    {
        for (auto &item : row)
        {
            std::cout << item.data << " ";
        }
        std::cout << std::endl;
        row=mysql.FetchRow();
    }
}
int main()
{
    LX::LXMysql mysql;
    if (!mysql.Init())
    {
        return 0;
    }
    if (!mysql.Connect("127.0.0.1", "root", "13356hhhhh", "test"))
    {
        return 0;
    }
    // mysql.Insert(LX::XDATA({{"name", "4.png"}, {"path", "D:/test/4.png"}, {"size", "123"}}), std::string("t_image"));
    // mysql.Insert(LX::XDATA({{"name", "4.png"}, {"path", "D:/test/4.png"}, {"size", "123"}}), std::string("t_image"));
    test_Exec_FetchRow(mysql);
}